<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $title=M("configs")->where("name='CFG_WEBNAME'")->getField("value");
        $search="/".MODULE_NAME."/search/index";
        $this->assign("title",$title);
        $this->assign("search",$search);
        $this->display("./Category_index");
    }
    //加载留言页面
    public function guest(){
    	if (IS_POST) {
    		$actionName 		= strtolower(CONTROLLER_NAME);
    		$data['name']  		= I('name', '', 'trim');
	        $data['email'] 		= I('email', '', 'trim');
	        $data['message']  	= I('content', '', 'trim');
	        $data['retime']	=time();
	        //获取留言页面
	        $data['url']		='http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
	        if (empty($data['name'])){
            	alertMes('留言姓名不能为空');
        	}
        	if (empty($data['email'])){
            	alertMes('邮箱不能为空');
        	}
        	if (empty($data['message'])){
            	alertMes('留言内容不能为空');
        	}
        	if(M('guestbook')->add($data)){
        		alertMes('留言成功');
        	}else{
        		alertMes('留言失败');
        	}
        }
		$this->display("/List_guest");
    }
       
}